package com.steakliu.event.order.listener;/**
 * @Title:
 * @author 刘牌
 * @date 2022-06-2519:35
 */

import com.steakliu.event.order.event.UserEvent;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

/**
 * 功能说明：账户监听器
 *
 * <p>
 * Original @Author: steakliu-刘牌, 2022-06-25  19:35
 * <p>
 * Copyright (C)2020-2022  小四的技术之旅 All rights reserved.
 */
@Component
@Slf4j
public class UserListener {

    @Async
    @EventListener(UserEvent.class)
    public void decreaseBalance(UserEvent userEvent) throws InterruptedException {
        log.info("扣减账户【{}】余额，扣减金额为:【{}】",userEvent.getUserDTO().getUserId(),userEvent.getUserDTO().getMoney());
    }
}
